﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefMaterialDoc" :model="stateMaterialDoc.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Code_FormItem" prop="Entity.Code" :label="$t('message.autotrans._Model_MaterialDoc_Code')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_Code')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Code" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Name_FormItem" prop="Entity.Name" :label="$t('message.autotrans._Model_MaterialDoc_Name')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Name" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Spec_FormItem" prop="Entity.Spec" :label="$t('message.autotrans._Model_MaterialDoc_Spec')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_Spec')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Spec" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Unit_FormItem" prop="Entity.Unit" :label="$t('message.autotrans._Model_MaterialDoc_Unit')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Unit" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ErpCode_FormItem" prop="Entity.ErpCode" :label="$t('message.autotrans._Model_MaterialDoc_ErpCode')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.ErpCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialProperty_FormItem" prop="Entity.MaterialProperty" :label="$t('message.autotrans._Model_MaterialDoc_MaterialProperty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_MaterialProperty')}), trigger: 'blur' }]" >
            <el-select v-model="stateMaterialDoc.vmModel.Entity.MaterialProperty" disabled clearable>
               <el-option key="Master" value="Master" :label="$t('message.autotrans._Enum_MaterialPropertyEnum_Master')"></el-option>
               <el-option key="Batch" value="Batch" :label="$t('message.autotrans._Enum_MaterialPropertyEnum_Batch')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_MaterialPropertyEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialType_FormItem" prop="Entity.MaterialType" :label="$t('message.autotrans._Model_MaterialDoc_MaterialType')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_MaterialType')}), trigger: 'blur' }]" >
            <el-select v-model="stateMaterialDoc.vmModel.Entity.MaterialType" disabled clearable>
               <el-option key="FERT" value="FERT" :label="$t('message.autotrans._Enum_MaterialClassifyEnum_FERT')"></el-option>
               <el-option key="HALB" value="HALB" :label="$t('message.autotrans._Enum_MaterialClassifyEnum_HALB')"></el-option>
               <el-option key="ROH" value="ROH" :label="$t('message.autotrans._Enum_MaterialClassifyEnum_ROH')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Expiration_FormItem" prop="Entity.Expiration" :label="$t('message.autotrans._Model_MaterialDoc_Expiration')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Expiration" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Rules_FormItem" prop="Entity.Rules" :label="$t('message.autotrans._Model_MaterialDoc_Rules')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_Rules')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Rules" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Supplier_FormItem" prop="Entity.Supplier" :label="$t('message.autotrans._Model_MaterialDoc_Supplier')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Supplier" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Pos_FormItem" prop="Entity.Pos" :label="$t('message.autotrans._Model_MaterialDoc_Pos')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Pos" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Active_FormItem" prop="Entity.Active" :label="$t('message.autotrans._Model_MaterialDoc_Active')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_Active')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialDoc.vmModel.Entity.Active" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_MaterialDoc_CreateTime')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_MaterialDoc_UpdateTime')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_MaterialDoc_CreateBy')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_MaterialDoc_UpdateBy')">
            <el-input v-model="stateMaterialDoc.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_MaterialDoc_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialDoc_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialDoc.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseMaterialDoc"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageWmsManagementMaterialDocDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { materialdocApi } from '/@/api/wmsmanagement/materialdoc';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefMaterialDoc = ref();
const stateMaterialDoc = reactive({
    vmModel: {
	  Entity:{
        Code: '',
        Name: '',
        Spec: '',
        Unit: '',
        ErpCode: '',
        MaterialProperty: undefined,
        MaterialType: undefined,
        Expiration: null,
        Rules: '',
        Supplier: '',
        Pos: '',
        Active: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
});

// 取消
const onCloseMaterialDoc = () => {
    closeDialog();
};

// 提交
const onSubmitMaterialDoc = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefMaterialDoc.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            materialdocApi().edit(stateMaterialDoc.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateMaterialDoc.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateMaterialDoc.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	materialdocApi().get(stateMaterialDoc.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateMaterialDoc.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

